using System;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
using log4net;
using Triton.Common;
using Triton.Common.LogUtilities;

namespace Triton.Bot.Settings
{
	public class Configuration
	{
		private static readonly ILog ilog_0 = Logger.GetLoggerInstanceForType();

		private static Configuration configuration_0;


		private readonly List<JsonSettings> list_0 = new List<JsonSettings>();

		public static Configuration Instance => configuration_0 ?? (configuration_0 = new Configuration());

        public string Name { get; set; }

		public List<JsonSettings> Settings => list_0;

		public void AddSettings(JsonSettings settings)
		{
			if (!list_0.Contains(settings))
			{
				list_0.Add(settings);
			}
		}

		public void RemoveSettings(JsonSettings settings)
		{
			list_0.Remove(settings);
		}

		public void SaveAll()
		{
			try
			{
				GlobalSettings.Instance.Save();
			}
			catch (Exception exception)
			{
				ilog_0.Error("[SaveAll] An exception occurred when saving GlobalSettings:", exception);
			}
			foreach (JsonSettings item in list_0)
			{
				try
				{
					item.Save();
				}
				catch (Exception exception2)
				{
					ilog_0.Error("[SaveAll] An exception occurred when saving:", exception2);
				}
			}
		}
	}
}
